input mode UserScript
Ctrl-]も受け付けるように改変したい
code:script.js
let isInputMode = true;
const enterInputMode = (e) => {
if (!isInputMode) {
if (e) {
e.preventDefault();
}
$("#text-input").prop('disabled', false);
$("#text-input").focus();
$('.page').css('background', '');
isInputMode = !isInputMode;
}
}
const exitInputMode = (e) => {
if (isInputMode) {
$("#text-input").prop('disabled', true);
$('.page').css('background', '#dadada');
isInputMode = !isInputMode;
}
}
const modeSelectors = {
true: exitInputMode,
false: enterInputMode,
}
scrapbox.PageMenu.addMenu({
title: 'Input mode',
onClick: () => {
},
});
$(window).keydown((e) => {
debugger;
if (e.keyCode === 73) { // key code of "i"
console.log(e);
enterInputMode(e);
}
if (e.keyCode === 27) { // key code of Esc
exitInputMode(e);
}
});
exitInputMode();